package com.study02;

public class TestDemo {
    public static void main(String[] args) {
        runnableMethod();
    }

    public static void threadMethod(){
        ThreadDemo threadDemo1 = new ThreadDemo();
        ThreadDemo threadDemo2 = new ThreadDemo();

        threadDemo1.start();
        threadDemo2.start();
    }
    public static void runnableMethod(){
        RunnableDemo runnableDemo = new RunnableDemo();
        Thread threadDemo1 = new Thread(runnableDemo);
        Thread threadDemo2 = new Thread(runnableDemo);

        threadDemo1.start();
        threadDemo2.start();

        // 线程优先级。

//        threadDemo1.setPriority(Thread.MAX_PRIORITY);  //1 = 10 normal 5
//        threadDemo2.setPriority(Thread.MIN_PRIORITY);

        // sleep 延时执行。
        try {
            Thread.sleep(500);
            System.out.println("所有的票已经卖完了");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
